// display the total potential VT(r) = V0(r)+VS(r)+VC(r)+VL(r)
// where VL(r) is the centrifugal barrier
// the data format is in 'r VT(r)'
// by Asia Sun, Feb. 6, 2023

static int co = 1; // graph color
void primp(TGraph *g); // primp the graph
// get the ymin and ymax of a file with two columns (x, y)
void mm(const string &file, double &mi, double &ma);

void v(){
  TLegend *lg = new TLegend(0.4, 0.6, 0.85, 0.85); lg->SetBorderSize(0);
  TGraph *gv = new TGraph("VT.txt", "%lg %lg");
  primp(gv); lg->AddEntry(gv, "\\frac{\\hbar^{2}}{2\\mu}\\frac{l(l+1)}{r^{2}}+V(r)");

  TCanvas *c = new TCanvas("c", "c", 800, 600);
  gv->Draw();
  lg->Draw();

  c->Print("v.pdf");
} // end main function mom

// primp the graph
void primp(TGraph *g){
  TAxis *ax = g->GetXaxis(); ax->SetTitle("r [fm]"); ax->CenterTitle();
  TAxis *ay = g->GetYaxis(); ay->SetTitle("VT(r) [MeV]"); ay->CenterTitle();
  co++;
  if(5 == co || 10 == co) co++;
  g->SetLineColor(co); g->SetMarkerColor(co); g->SetLineWidth(2);
} // end function primp

// get the ymin and ymax of a file with two columns (x, y)
void mm(const string &file, double &mi, double &ma){
  ifstream f(file); double x, y;
  while(f >> x >> y){ mi = min(mi, y); ma = max(ma, y); }
} // end main function
